package cn.jiyun.controller;

import cn.jiyun.openfegin.EmployeeClient;
import cn.jiyun.pojo.Employee;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.RestTemplate;

import java.util.List;

@RequestMapping("xiaofeizhe")
@Controller
public class EmployeeController {
    @Autowired
    private EmployeeClient employeeClient;
    @RequestMapping("diaoyongTigongzhe")
    @ResponseBody
    @HystrixCommand(fallbackMethod = "findAll")
    public Employee getAll(){
        Employee all = this.employeeClient.getAll();
        return all;
    }
    public Employee findAll(){
        Employee employee = new Employee();
        employee.setName("请求异常，请重试");
        return employee;
    }
}
